package com.apes.autoparts.parts.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ModelProp.CONST_TABLE_NAME)
public class ModelProp extends BaseModel {
    public static final String CONST_TABLE_NAME = "auto_model_prop";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车型属性")
    @Comment("唯一码")
    private String id;

    @Column(name = "key", length = 32)
    @Comment("属性代码")
    private String key;

    @Column(name = "value", length = 4000)
    @Comment("属性值")
    private String value;

    @ManyToOne(optional = false)
    @JoinColumn(name = "selector_id", referencedColumnName = "id")
    @Comment("车型")
    private AutoModel selectorId;

    @Column(name = "timestamp")
    @Comment("时间戳")
    private Date timestamp;
}
